home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
ab20
/
ab20_archive
/
utilities
/
shells
/
csh519.lha
/
csh.doc
< prev
next >
Wrap
Text File
|
1992-02-25
|
91KB
|
2,632 lines
INSTRUCTIONS FOR C-SHELL VERSION: 5.19 January 1992
====================================================
Contents
--------
O. Installation
I. Description
II. Overview of major features
III. Restrictions
IV. PIPES
V. Command Pre-processor
VI. Command Line Editing
VII. Function Keys
VIII. Shell Commands
IX. Special Set Variables
X. Functions
XI. Miscellaneous
XII. Example source files
XIII. Default values
XIV. Object oriented features
XV. Keymaps
O. Installation
----------------
For online help inside csh, assign CSH: somewhere and put csh.doc there.
Then you can use the 'man' command for any desired command. Press the HELP
key for a command list.
You can simply invoke csh from the command line or at the end of your
startup-sequence, because csh is, from the AmigaDOS standpoint, not a true
shell like l:shell-seg. Nevertheless, csh is 'pure', so if your archiver
forgot to set the 'p' bit, do it right now.
Proposed final setup: If you want to make csh resident, do the following:
- Kickstart 1.3
1. Copy csh anywhere on your (hard)disk, e.g. dh1:tools
2. Make sure your s:startup-sequence contains:
Resident CLI L:Shell-Seg SYSTEM PURE ADD
Resident dh1:tools/csh ADD
NewShell FROM s:csh-startup
EndCLI
3. Put the following in s:csh-startup
Stack 8000
csh -r s:firstlogin.sh
4. In s:firstlogin.sh, put any commands to be called only once, like setmap,
assign, setclock. This is a shell script, use # for comments, and
don't use .key type commands. At the end of this file, add
source s:login.sh
5. In s:login.sh, you put any commands that need to be executed on every
invocation, like 'alias', 'set' and so on.
6. Put the following the s:cli-startup and s:shell-startup, so csh will be
started in any window opened by NewCLI, NewShell or from workbench.
csh s:login.sh
- Kickstart 1.3 plus existing ARP shell:
Not recommended anymore, since the ARP shell is not 2.0 compatible and
each csh invocation takes 55K of memory instead of 30K then. You best
remove the ARP shell, maybe retaining some ARP commands.
- Kickstart 2.0
1. Copy csh anywhere on your (hard)disk, e.g. dh1:tools
2. Make sure your s:startup-sequence contains:
Stack 8000
Resident dh1:tools/csh ADD
csh s:firstlogin.sh
3. Proceed from step 4 in kickstart 1.3
Additionally, I recommend to assign CSH: somewhere and put your docs and
CShell scripts there. You can do the assign from inside the shell, it's not
needed at startup.
The file s:.login is executed on every startup if it exists.
I. DESCRIPTION
---------------
This version of Shell is the successor of:
Shell V2.04 (C)Copyright 1986, Matthew Dillon, All Rights Reserved
Shell V2.04M-V2.07M by Steve Drew
Shell V2.08MI, V3.xxA and V4.xxA by Carlo Borreo & Cesare Dieni
Shell V5.xxL by U. Dominik Mueller
If you have any wishes, bug reports or beer bottles, send them to:
FIDONET : Urban Mueller@2:302/906 (AUGL)
INTERNET: umueller@iiic.ethz.ch
umueller@amiga.physik.unizh.ch
or
U. Dominik Mueller
Schulhausstrasse 83
CH-6312 Steinhausen
SWITZERLAND
Any sign of intelligent life welcome! German, English and French spoken.
Please check the 'restrictions' chapter before reporting any bugs and add
your CShell version and a description of your configuration. The support BBS
is AUGL (2:302/906), +41 75 8 20 19, +41 75 8 20 18, +41 75 2 15 87 (all
lines USRobotics HST or V.32), login='cshell', password='support'.
You may distribute this program unmodified and for non-profit only.
*** YOU MAY NOT MODIFY THIS PROGRAM AND REDISTRIBUTE IT ***
Please contact me if you want to make changes.
AVAILABILITY
------------
CShell can always be downloaded at the AUGL BBS. Some additionals parts
(French documentation) are available there, too.
For those who want to get it per FIDO file request, the archive is always
named like 'csh513.lzh' for CShell 5.13 and 'csh513s.lzh' for its source.
For FTP or bitnet file requests at ab20.larc.nasa.gov [128.155.23.64], the
archive names are the same, and they're sited either in the directory
/incoming/amiga or in /amiga/utils/system/cli/shells.
You can get the French doc from AUGL or order it for 20 French Francs at:
BUGSS
4, Place de L'Aube
33170 GRADIGNAN
FRANCE
Direct any questions to berger@geocub.greco-prog.fr .
CREDITS
-------
Arexx is a program by William Hawes.
Cygnus Ed Professional (C) 1988 CygnusSoft Software.
ARP is copyrighted by the authors.
Thanks to:
Matt Dillon, Steve Drew, Calro Borreo and Cesare Dieni for the previous
versions of Csh.
Eddy Carroll, Gary Duncan, Randell Jesup, Steve Koren, Tim MacKenzie, Axel
Roebel, Mike Schwartz for their code contributions and suggestions.
Michael Beer, Carl Johan Block, Hubert Feyere, Magnus Heldestad, Carsten
Heyl, Alex Liu, Declan McArdle, Svante Eriksson, Luke Mewburn, Peter Orbaek,
Allard Siemelink, Roddi Walker, Shimon Weissman and the unknown Swedish guy
who found the double-LF bug for their bug reports amd feedback.
Roy Haverman, Martin Horneffer, Hans-Christian Huerlimann, Daniel Pfulg,
Patrizio Rusconi, Christian Schneider and especially Markus Illenseer for the
German translation of the doc.
Olivier Berger for the French translation of the doc.
II. OVERVIEW
------------
Shell provides a convenient AmigaDos alternative command interface. All its
commands are internal and thus it does not rely on the c: commands for any
functionality.
Major features include:
- freely programmable command line editing
- simple history
- piping
- aliases with arguments
- variables & variable handling (embedded variables)
- file name expansion via wild carding ('?', '*' and more)
- conditionals (if/else etc..)
- source files (w/ gotos and labels)
- tab file name completion
- object oriented features (file classes, actions)
- many built in commands to speed things up
- full functionality on VT terminals
CShell runs on minimum stack, for recursive aliases and source files better
increase stack to 8K or more.
If you use CShell for the first time, remember the following:
- CShell internal commands must be lowercase & can be abbreviated
- AmigaDOS command 'Execute' causes some trouble. You cannot redirect
it, you must not rename it, and you get no return code.
You can also use 'source' to start your scripts, but you'll have
to rewrite them a bit. Besides the '.key'-type commands, 'source'
is downward compatible with 'Execute'.
- You can always get more information on a command if csh.doc is
in the current directory or in csh: (you will be able to modify
this) and you enter 'man <command>'
- The wild card #? doesn't work. Use *
III. RESTRICTIONS
-----------------
The following applies only to the V36 version of Kickstart 2.0: The INTERNAL
commands cannot be started. The same is true for the commands in C: if they
were made resident using the AmigaDOS 'Resident' command (with cshell's
'resident' they work). Thus, you should disable the INTERNAL residents using
the -i0 startup option if you have a V36 Kickstart.
Under 1.3, you can't start AmigaDOS residents directly. But you can use the
-r startup option, which will copy the AmigaDOS resident list to the ARP
resident list once (and make those residents unremovable). I'll try to find
a better solution.
The best choice under both kickstarts is to make only csh itself AmigaDOS
resident, all other commands, if any, ARP resident. Under 1.3, you can start
the shell (as any other commands) from the resident list only after you did
'resident CLI l:Shell-seg' and 'newcli'.
The c:Execute command cannot be redirected, does not return error codes, and
might cause other problems. It will not work at all if it has been renamed.
The VDK: handler and Frank Seidel's BootRam-Handler have a bug with setting
file dates, so when using the copy command you should try the -d and -p
switches, otherwise your file date will be bad. (This is not a shell bug)
If using it with conman you may consider starting shell with the -a switch to
turn off shell's command line editing and use conmans instead. You'll lose,
however, many shell features like file name completion.
CB-handler (a tool that installs a scrollbar in the CLI window) is not 100%
compatible with cshell. The log will not always represent the real screen
contents.
IV. NOTES ON PIPES
------------------
PIPES
PIPES have been implemented using temporary T: files. Thus, you
should be careful when specifying a 't:*' expansion as it might
include the temporary files. These files are deleted on completion
of the pipe segment.
The file names used are completely unique, even with multiple shell
running simultaneously.
My favorite new feature is the fact that you can now redirect to
and from, and pipe internal commands. 'echo charlie >ram:x', for
instance. Another favorite:
echo "echo mem | csh" | csh
No BCPL program should be output-append redirected (>>).
V. COMMAND PRE-PROCESSOR
-------------------------
PREPROCESSING
Preprocessing is done on the command line before it is passed on to
an internal or external routine:
^c where c is a character is converted to that control character.
Thus, say '^l' for control-l.
\233 insert character code 233 octal. Do not use values between
200o and 232o, as they have special meanings. \240 is the
word separator.
$name where name is a variable name. Variable names can consist of
0-9, a-z, A-Z, and underscore (_). The contents of the
specified variable is used. If the shell variable doesn't
exist, csh tries to find and ENV: variable of the same name.
If that fails, too, "$name" is inserted.. That is, if the
variable 'i' contains 'charlie', then '$i' -> 'charlie'. If
the variable 'i' doesn't exist, then '$i'->'$i' .
; delimits commands. echo charlie ; echo ben.
' ' (a space). Spaces delimit arguments.
"string" a quoted string. Trailing quotes are optional. For instance,
if you want to echo five spaces and an 'a':
echo a -> a
echo " a" -> a
\c override the meaning of special characters. '\^a' is a
circumflex and an a rather than control-a. To get a backslash,
you must say '\\'.
also used to overide alias searching for commands.
>file specify output redirection. All output from the command is
placed in the specified file.
>>file specify append redirection (Does not work with BCPL programs).
<file specify input redirection. The command takes input from the
file rather than the keyboard (note: not all commands require
input; it makes no sense to say 'echo <charlie' since
the 'echo' command only outputs its arguments).
| PIPE specifier. The output from the command on the left becomes
the input to the command on the right. The current SHELL
implimentation uses temporary files to store the data.
!! execute the previously executed command.
!nn (nn is a number). Insert the history command numbered n (see
the HISTORY command)
!partial search backwards through the history list for a command which
looks the same as 'partial', and execute it.
# enter comment. The rest of the line is discarded (note: \#
will, of course, overide the comment character's special
meaning)
{e hi;e ho} executes two commands as one, so they can be redirected
together (see ALIAS command). The trailing curly brace is
optional.
$(foo) insert the stdout of the command 'foo' at this position of
the command line. Every line of the output will count as one
argument. The closing parenthesis is optional.
`foo` insert the stdout of the command 'foo' at this position of
the command line. Every blank separated word will count as
one argument. Leading, trailing and multiple blanks will be
removed. The trailing backtick is optional.
-- stop option parsing here. Works for internal commands only.
Example: rm -- -x will remove the file '-x'
Please note the subtle differences between
alias count {echo one;echo two}
alias count "echo one;echo two
The first form will create an alias that contains a local alias. The
other will create a plain alias. Also, things within braces will not
be parsed more than once, therefore a backslash needs not be pre-
ceded by a pair of backslashes. Thus the commands look the same as
if they were to be typed in at the prompt. To echo lots of '#',
either use:
forever {echo \#
forever "echo \\\#
A block can spread over several lines. Refer to the SOURCE command.
VI. COMMAND LINE EDITING
------------------------
o The command line can be up to 255 chars.
o Inserts and deletes are handled correctly over multiple lines.
o The script 'menu.sh' installs an intuition menu that contains most
editing functions
EDITING
-- MOVING --
Left Arrow One character left
Right Arrow One character right
Shift-Left Arrow One word left
Shift-Right Arrow One word right
ESC-Left Arrow Beginning of line (^A) (^Z)
ESC-Right Arrow End of line (^E)
-- DELETING --
Backspace Previous character
Del Character under cursor
ESC-Backspace Previous word (^W)
ESC-Del Next word
ESC-x-Backspace To start of line (^B)
ESC-x-Del To end of line (^K)
ESC-d Entire line (^X)
-- HISTORY --
Up Arrow Recall previous commands
Down Arrow Recall commands
Shift-Up Arow Get history from partial (or number)
Shift-Down Arrow Go below last command of history
ESC-Up Arrow Get start of history
ESC-Down Arrow Get end of history
ESC-! Get history from partial (or number)
^T Insert tail (all but first word) of previous line
^P Duplicate previous word (useful for mv)
-- COMPLETION --
TAB Inserts first matching file name
Shift-TAB Inserts longest common substring
ESC-TAB Inserts all matching file names (also ESC-*)
ESC-c Does a quick cd on left word (TAB for cycling)
ESC-~ Inserts the last current directory
^D Shows all files that match a pattern (also ESC-=)
-- EXECUTING LINE --
Return Executes line
ESC-Return Executes this line of history & brings up next one
^N Next line. Don't exec this one but store history
^\ EOF (directly exits)
-- MISCELLANEOUS --
^L Retype current line.
^O Echo a ^O
^R Repeat last command (don't play with this)
^U Undo/Redo last edit
ESC-i Toggle Insert/Overwrite
f1-f10 Execute command if variable exists.
F1-F10 More commands (Shifted f keys).
Help Invokes help command
Whenever the cursor is placed on or directly after an incomplete file name
and you press TAB, CShell inserts for the first filename (sorted
alphabetically) that matches the name part already typed. Any wildcards
are allowed here, if none are given, '*' is appended. Immediately pressing
TAB again brings up the next file name that matched the substring.
Shift-TAB will only insert the as much as is common to all files that
matched your abbreviation. If pressed again, behaves just like TAB.
ESC-Tab inserts the name of the directory where you would have ended up
with a quick cd to that substring.
Note that ^D now means 'quit batchfile' like under AmigaDOS and is no
longer used for quitting CShell. If you want it back, enter 'keymap 0 4=41'
The CTRL keys FGVY are unset, feel free to map them to any function (see
chapter XV). You can also remap all preset keys.
VII. FUNCTION KEYS
------------------
FUNKEY
Function keys now insert text to the current position on the command
line. They maybe terminated with a ^M (return). f1 would be non shifted
where as F1 is shifted.
Most of functions key have a default definition, but it may be changed.
$ set f1 dir df0:^M
will add the text 'dir df0:<return>' to the current line.
$ set f1 dir
would only add 'dir' you could then enter ' df0:<return>'
VIII. SHELL COMMANDS
--------------------
STARTUP OPTIONS
First to start shell from a CLI:
csh [-abcCfiknstv] [-c command;command]
csh [-abcCfiknstv] [batchfile1 ... batchfileN]
-a AUX: mode. No command line editing and text highlighting
-b starts shell in background, which means only task priority -1.
-c allows execution of one command line and then exits out
of shell. This is useful for running an internal shell
commands in the background or from an external application:
run csh -c "dir df0:; copy -r df0: df1: >nil:; echo Done"
-C same as -c, but the command line is not parsed twice. This
allows passing of file names with blanks within.
run csh -C rm "Ram Disk:tempfile"
-f starts shell in foreground, which means only task priority 1.
you might reset this prioritiy to 0 at the end of your .login
-i0 disables INTERNAL residents. For V36 kickstarts.
-k sets _nobreak before doing anything
-n suppresses starting of s:.login
-r copies the Amiga resident list to the ARP resident list. You
can't remove them anymore. No copying when under kick 2.0 or
if ARP residents present.
-s globally enables the asterisk * as alias for #? in AmigaDOS 2.0.
This means you can use * inside file requesters as well.
-t terminal mode. You can use command line editing and text high-
lighting on a VT100 compatible terminal. To swap backspace
and DEL, refer to the 'keymap' command
-v sets _verbose to 'hs' before doing anything.
Under 1.3, the best thing you can do is to make csh resident using
the AmigaDOS Resident command in the startup-sequence, then start
it with the option -r, so you can start another resident csh from
inside csh. NOTE: Residents copied using -r cannot be removed! I
advise you to use the internal resident command for all but csh
itself.
COMMAND EXECUTION
Internal shell commands are case sensitive and may be abbreviated.
The first argument is the command-name... here is (in order) how Shell
tries to execute it:
1) The alias list is searched for an alias with an exactly
matching name.
2) Internal commands list is scanned for a command even partially
matching name (so you can, for instance, say resi for resident;
however, you should specify enough of a command to be unique).
3) Then, the list of functions is scanned for a command that
matches completely. If one is found, the result of the function
is echoed to stdout.
4) Now the command is assumed to be external. Arguments with blanks,
semicolons or empty strings will be surrounded by quotes.
5) If the file is a directory, a 'cd <file>' will be performed to
it.
6) AmigaDOS and ARP resident list are scanned for it (you can use
Shell's 'resident' command to add/remove a file in the ARP list).
7) If the file is in the current directory and it's executable, it
is started.
8) Then it is searched in the AmigaDOS path and c: (NOTE: Path
assigns to C: under Kickstart 2.0 don't work; use 'path')
9) Now, the shell path ($_path) is searched. If it's found and
executable, it's started. If it has the 's' bit set, it will
be executed using the appropriate shell. See FOREIGN SHELLS
10) If there exists a file with the suffix '.sh' and the same root
in the current directory or in the shell path, it is 'source'd.
11) Then the variable _rxpath is examined. If there exists a file
with the suffix '.rexx' and the same root in the current direc-
tory or in '$_rxpath', 'RX <file>' will be performed.
12) If all failed, an 'exec' action is sent to the file. See chapter
XIV for more info on classes and actions.
To enforce that the external 'dir'-command is used, enter 'Dir'. It
is a good habit to uppercase the first letter of all external com-
mands, even if this is not necessary.
AUTOMATIC SOURCING may be accomplished by naming shell scripts with
a .sh suffix. Thus, if you say 'stuff' and the file 'stuff.sh'
exists in your current or anywhere in Shell search path (NOTE: won't
be found in the AmigaDOS path), it will be SOURCED with all arguments
you have given placed in the $_passed variable. This is equivalent
to typing 'source stuff.sh'
FOREIGN SHELLS are supported through key characters at the beginning
of their scripts. If a file in $_path has the s-bit set, the first
few bytes are read. If the first two are either '#!' or ';!', the
rest of the first line will be interpreted as the name of the shell
that is supposed to execute the script. If they are '/*', the command
'RX' is used, if none of the above, 'c:Execute'.
Example:
#!SKsh -c source
WILDCARDS
Most shell commands will accept multiple arguments that can
be as a result of wild card expansion. Also when calling
an external command shell will first expand any wild cards
to separate arguments. If you wish to have the external command
handle it's own wild carding you will need to insert quotes
around the special wild card characters or use an alias (see
explanation of 'alias')
eg.
arc a new.arc *.txt - shell will expand and pass to arc
arc a new.arc "*.txt" - let arc expand the wild cards.
alias arc "*a Arc $a" - now shell will never expand
Wildcards allowed:
? match any single character
* match any string
.../* recursive search down ALL sub directories from current level
~ exclude pattern matching specifier
! synonym for ~, supported for compatibility
& prefixed to patterns, ask confirmation for each file
[] character class
~ the previous current directory (if separated)
Note that a pattern must contain a '?' or a '*', otherwise the other
special characters are not recognized. Furthermore, you cannot spe-
cify a single '?' as a pattern in the first argument to a command,
as this will be passed on to the command in order to show its usage.
If pattern.library is present it LIBS:, it will be used for the
matching.
Examples:
df0:.../* all files in all directories on df0:
df0:.../!*.info full directory tree of df0: but exclude
any ugly .info files.
!*.o !*.c will result in ALL files matching since what
doesn't match the !*.o will match the !*.c
df1:&* all files in root of df1:, but ask
confirmation for each
*.[co] all files ending in .c or .o
~*.[co] all files NOT ending in .c nor in .o
~ the previous current directory
~/*.c all .c files in the previous current directory
~// the parent of the previous current directory
. the current directory
./foo.c the same as foo.c
.. the parent of the current directory
../foo.c the file foo.c in the parent directory
Note that some commands prevent wild card expansion. These are:
- dir, rpn, whereis, window
Those commands will expand the wild cards themselves. This is why
dir @without( *.? , *.o )
will not work. Instead use:
set arg @without( *.? , *.o );dir $arg
There is one exception to the rules given above: A single '?' as
the first argument will *not* expand in order to allow you to get
the usage of CLI and csh commands easily.
The following symbols are not yet supported by wild card
expansions, but are accepted in search -w and @match( ):
( | ) OR matching
# 0 or more times the pattern following
Examples:
"k#a" matches ka, kaa, kaaa, etc.
"hel(lo|p)" matches hello or help.
LIST OF COMMANDS:
-----------------
ABORTLINE
Usage : abortline
Example : echo a;abort;echo b
Results : a
Causes the rest of the line to be aborted. Intended for use in
conjunction with exception handling.
ACTION
Usage : action [-a] actionname file [arguments]
Example : action extr csh515.lzh csh.doc
Sends an action to a file. See chapter XIV CLASSES
Options:
-a (abort) returns 0 if failed and 1 if successful. Otherwise,
normal error codes (10 or 11) are returned
ADDBUFFERS
Usage : addbuffers drive buffers [drive buffers ...]
Example : addbuffers df0: 24
Just like AmigaDOS addbuffer command, causes new buffers to be
allocated for disk I/O. Each buffer costs 512 bytes of memory,
CHIP memory if a disk drive.
ALIAS
Usage : alias [name [command string] ]
Example : alias vt "echo Starting VT100;run sys:tools/vt100"
Sets a name to be a string. You can alias a single name to a set
of commands if you enclose them in quotes as above. By simply
typing vt, the command line above would be executed.
Aliases may call each other, but direct recursion is prohibited,
so the following works: alias ls "ls -s"
To prevent alias replacement, enter: \ls
By typing "alias name", you will get the alias for that name, while
with "alias" you get a list of all alias.
ARGUMENT PASSING TO AN ALIAS:
Usage : alias name "%var[%var...] [ command_string ]"
alias name "*var[%var...] [ command_string ]"
Example : alias xx "%q%w echo hi $q, you look $w
xx Steve great today
Results : hi Steve, you look great today
The second form of the alias command allows passing of arguments
to any position within the command string via use of a variable
name. To pass arguments to the end of a command string this method
is actually not necessary. These variables are local, so they don't
destroy another variable with the same name.
If you specify multiple arguments, every argument will be assigned
one word, and the last argument will be assigned the rest of the
command line.
Using a '*' instead of the first '%' prevents wild card expansion:
alias zoo "*a zoo $a
To expand the wild cards after you got them, use
exec set a $a
IMPLICIT ALIASES:
Usage : {command;command}
{%var command;command} arg arg
Example : {%tmp echo $tmp $tmp} hello --> hello hello
Curly braces define temporary aliases. They can be redirected as
a whole, can have arguments and local variables. They count as
one argument, even if there are blanks inside (as with quotes), and
they may be nested. Complex alias definitions can use the braces
instead of quotes, although this will add some calling overhead.
The closing curly brace is optional if at the end of line.
Example:
alias assert {e "Are you sure? ";input -s sure
ASCII
Usage : ascii
ascii string
If called without arguments, ascii outputs a complete ASCII table.
Given a string, shows each character in ASCII. Options:
-h shows numbers in hexadecimal
-o shows numbers in octal
ASET
Usage : aset name value
Example : aset INCLUDE include:
Set a variable in a way that is compatible with ARP/old Aztec set
command; this is completely different from ENV: Shell variable.
This is obsolete. Use setenv instead.
ASSIGN
Usage : assign
assign logical
assign [-lnp] logical1 physical1 [logical2 physical2 ... ]
The first form shows all assigns.
The second form kills one assign.
The third form assigns logical1 to physical1 and so on. Options:
-l creates a late-binding assign under kick 2.0, normal otherwise
-n creates a non-binding assign under kick 2.0, normal otherwise
-p creates a path-assign under kick 2.0, cancelled otherwise
For definition of late/nonbinding, refer to your AmigaDOS manual.
BASENAME
Usage : basename var path [path ...]
Example : basename x df0:c/Dir # sets x to "Dir"
Sets var specified to basenames of paths.
CAT
Usage : cat [-n][file file....]
Example : cat foo.txt
Type the specified files onto the screen. If no file is specified,
STDIN in used (note: ^\ is EOF). CAT is meant to output text files
only. Specifying -n option you will output numbered lines.
CD
Usage : cd [path]
cd -g device1 [device2 [device3 ...]]
Change your current working directory. You may specify '..' to go
back one directory (this is a CD specific feature, and does not
work with normal path specifications).
In most cases, you'll no more have to use the CD command. Just type
the desired directory at the prompt (very handy in conjunction with
file name completion). Typing a ~ alone on a command line cd's
to previous current directory.
There are two situations left when you still need it:
Entering 'cd *tem' will cd to the first name matched.
The second form generates a list (an ASCII file) of all direc-
tories on the given devices. It will be stored in the file given
in $_qcd (default: 'csh:csh-qcd'). Note that this ASCII file will
not be merged but overwritten. Once you have generated this file,
you can cd to any directory on your harddisk(s) even if it's not
in the current directory.
If you have two directories of the same name and you use one of
them more, move the more important one to the beginning of the
qcd file. You might also sort the file.
It is legal to type just an abbreviation of the directory name
you want to cd to. No asterisk '*' necessary. If you end up in
the wrong directory, cd to the same directory again (best done
by Cursor-Up + RETURN). You will cycle through all directories
that matched the given abbreviation. The other possibility is to
specify the full name of the parent directory: cd devs/keym
You may also add devices and assigns, so if 'PageStream:' is one
line in the qcd-file, a cd to 'page' is successful.
CD without any arguments displays the path of the directory you
are currently in.
CLASS
Usage : [-n] name {type=param} [ "actions" {action=command} ]
Example : class zoo offs=20,dca7c4fd ext=.zoo actions view="zoo l"
Defines a new class of files and the actions to be taken on them
in various cases, or shows old definitions if given no arguments.
See section XIV: OBJECTS
Options:
-n (new) forgets old definitions
CLOSE
Usage : close [filenumber]
Close the specified file opened by open. Without filenumber, closes
all open files. See open and flist for more info.
CLS
Usage : cls
This is an alias. It only clears the screen, but also works on a
terminal (echo ^L doesn't).
COPY
Usage : copy [-udfpm] file file
or : copy [-udfpm] file1 file2...fileN dir
or : copy [-rudfp] dir1...dirN file1...fileN dir
Options :
-r recursive, copy all subdirectories as well.
-u update, if newer version exists on dest, don't copy
-f freshen, if file doesn't exist on dest or newer, don't copy
-q suppresses 'not newer' and 'not there' messages in -u and -f
-d don't set destination file date to that of source.
-p don't set destination protection bits to those of source.
-m erases the original. does not work with -r
-o overwrites write/delete-protected, reads read-protected
Example : copy -r df0: df1:
Copy files or directories. When copying directories, the -r option
must be specified to copy subdirectories as well. Otherwise, only
top level files in the source directory are copied.
All files will be displayed as they are copied and directory's
displayed as they are created. This output can be suppressed by
redirecting to nil: eg. copy -r >nil: df0: df1:
Copy will abort after current file on Control-C.
Copy by default sets the date of the destination file to that of
the source file. To overide this feature use the -d switch.
Similarly, it sets protection bits (flags) to those of source and
any file comment will be copied. To avoid this use -p. The archive
bit is always cleared.
Another useful option is the -u (update) mode where copy will not
copy any files which exists already in the destination directory
if the destination file is newer or equal to the source file.
This is useful when developing code say in ram: eg. 'copy *.c ram:'
when done you can copy -u ram: df1: and only those modules you have
modified will be copied back.
Copy command will now create the destination directory if it does
not exist when specified as 'copy [-r] dir dir'. If you specify
copy file file file dir, then 'dir' must already exist.
CP
Equivalent to copy.
DATE
Usage : date [-sr] [new date and/or time]
Example : date Wednesday # this refers to NEXT wed, of course
Options:
-s stores the current time internally
-r shows time relative to last stored in secs and hundredths
Used to read or set system date and/or time. All standard options
may be used (yesterday, tomorrow, monday, etc.).
Leading zero's are not necessary.
Without parameters shows Dddddd DD-MMM-YY HH:MM:SS.
DEC
Usage : dec varname [value]
Example : dec abc
Decrement the numerical equivalent of the variable with specified
value (default: 1) and place the ASCII-string result back into
that variable.
DELETE
Usage : delete [-p][-r][-q] file file file...
Example : delete foo.txt test.c
Remove (delete) the specified files. Remove always returns
errorcode 0. You can remove empty directories. The '-r' option
will remove non-empty directories by recursively removing all sub
directories.
You can remove delete-protected files specifying -p option.
If you specify any wildcard deletes the files will be listed as
they are deleted. This can be suppressed by redirecting to nil:
If you specify -q, no error message will be supplied if the file
to be removed didn't exist or couldn't be deleted.
DIR
Usage : dir [-abcdfhiklnoqstuv] [-z lformat] [path path ... ]
Example : dir -ts downloads:
dir -lz "%7s %-.16n %m" *.c
Options:
-d list directories only
-f list files only
-h list only files which not start with a dot, end with '.info' or
have the h-flag set. Adds an 'i' bit to the flags which tells
if an according .info file exists.
-s short multi(4) column display.
-c don't change colors for directories
-q quiet display. does not show length in blocks
-o display file nOtes
-n display names only
-p display full path names and suppress directory titles
-a shows the age of all files in the format days hours:minutes
-i identifies every file, shows the type instead of the date.
See chapter XIV CLASSES
-v (viewdir) recursively sums up lengths of the files in a dir
-l sorts the files by their length, longest first.
-t sorts the files by their time, most recent first.
-k sorts the files by their class (klass)
-b sorts the files backwards.
-g prints directories at the beGinning
-e prints directories at the End
-u must be given exactly two directories. Shows files only in
the first directory, files in both and files in the second.
-z custom format
Displays a directory of specified files. Default output shows
date, protection, block size, byte size and total space used.
Protections flags include new 1.2/1.3 flags (see under protect),
plus a 'c' flag which indicates that this file has a comment.
Files are alphabetically sorted, without case sensitivity, and
directories are in red pen (unless you use -c). Dir takes in
account the width of your window.
The lformat string is used to create your own directory format.
It will override all else and may contain the following codes:
%a age %l LF if comment %t time
%b size in blocks %m multi column %u size in K
%c flag c (comment) %n name %v dir size in eng.
%d date %o filenote (comment) %w dir size in K
%e flag i (.info) %p name w/ path %x translated date
%f flags hsparwed %q name w/ slash %+ flag i as '+' or ' '
%i flag d (dIr) %r size in eng.
%k class %s size
Between the '%' and the identifying letter, there may be an optional
field width. If the number is preceded by a '-', the field contents
will be left adjusted. If by a dot, the contents will be cut down
to match the field width if they are longer.
If the format string contains a %m, cshell will try to print more
than one entry on one line. The column width is the field width of
the %m entry. If omitted, it's assumed to be the one of the first
file. If a file is longer, it will use two columns.
DISKCHANGE
Usage : diskchange drive
Like AmigaDOS diskchange.
ECHO
Usage : echo [-en] string
Example : echo hi there
Results : hi there
Echo the string given. If -n switch given no newline is
appended. If -e is on, echo to stderr.
ELSE
Usage : else ; command
Usage : if -f foo.c ; else ; echo "Not there" ; endif
Else clause, must follow an IF statement.
ENDIF
Usage : endif
The end of an if statement.
Note: if you return from a script file with unterminated IF's
and the last IF was false, prompt will be changed to an
underscore ('_') and no commands will be executed until
'endif' is typed.
ERROR
Usage : error n
Generates return code n.
EXEC
Usage : exec [-i] command [args]
Example : set cmdline "dir ram:"
exec $cmdline # would not work without exec
Execute the command specified; exec command is equivalent to
command, only you can use variables to specify command name.
Note that the command line is parsed TWICE! Examples:
set a dir ram:; exec $a # right
set a mkdir; exec $a "My directory" # wrong! creates 2 directories
Exec returns the return code of the command executed unless option -i
(ignore) is set, in which case always 0 is returned.
FAULT
Usage : fault error1 .. errorN
Example : fault 205 212
Like AmigaDOS fault, prints specified error messages.
FILENOTE
Usage : filenote file1 .. fileN note
filenote -s file1...fileN
The first form sets AmigaDOS comment of the specified file.
The second form displays the file notes of the given files.
FLIST
Usage : flist
Lists the filenumbers of files opened by open.
See open and close for more info.
FLTLOWER
Usage : fltlower
Example : dir | fltlower
Or : fltlower <readme
This is a filter command, i.e. it reads from stdin and writes to
stdout. The more natural way to use it is a pipe, or it can be
redirected.
Its purpose is to convert all alphabetic to lower case.
FLTUPPER
The same of fltlower, only this converts to upper case.
FOREACH
Usage : foreach [-v] varname ( strings ) command
Example : foreach i ( a b c d ) "echo -n $i;echo \" ha\""
Result : a ha
b ha
c ha
d ha
'strings' is broken up into arguments. Each argument is placed in
the local variable 'varname' in turn and 'command' executed. Put
the command(s) in quotes.
Foreach is especially useful when interpreting passed arguments in
an alias.
eg.
foreach i ( *.pic ) viewilbm $i
assuming a.pic and b.pic in current directory the following commands
will occur:
viewilbm a.pic
viewilbm b.pic
Flag -v causes arguments to be displayed every time command is
executed. All 'for...' commands can be interrupted using CTRL-D.
FOREVER
Usage : forever command
or : forever "command;command;command..."
The specified commands are executed over and over again forever.
Execution stops if you hit ^C or ^D, or if the commands return with
an error code.
FORLINE
Usage : forline var filename command
or : forline var filename "command;command..."
Example : forline i RAM:temp "echo line $_linenum=$i"
For each ASCII line of file specified commands are executed and
var points to line content. You can check system variable _linenum
to find the number of the line currently read.
If STDIN (case sensitive) is specified as input file, the lines are
read from standard input.
FORNUM
Usage : fornum [-v] var n1 n2 command
or : fornum [-v] -s var n1 n2 step command
Example : fornum -v x 1 10 echo $x
or : fornum -s x 10 1 -1 echo $x # counts backwards
Executes command(s) for all numerical values of x between n1 and
n2. If more than one command is specified, or command is
redirected, include command(s) in quotes.
Switch -v (verbose) causes printing of progressive numbers.
Switch -s allows you to specify a step; if this is negative, the
count will be backwards.
GETENV
Usage : getenv [shellvar] envvar
Gets the value of an ARP or ENV: variable (ARP list searched first)
and stores it in the shell variable 'shellvar'. If shellvar is
omitted, the value of the ENV: variable is printed to stdout.
This command is obsolete since ENV: variables can be retrieved
by writing $envvar anywhere on the command line.
GOTO
Usage : goto label
Example :
label start
echo "At start"
dir ram:
goto start
Goto the specified label name. You can only use this command from
a source file. Labels may be forward or reverse from current
position. It is legal to jump out of if's.
HEAD
Usage : head filename [num]
Example : head readme 20
Display first "num" lines of "filename". If num is not specified,
10 is assumed.
HELP
Usage : help
Example : help
Simply displays all the available commands. The commands are
displayed in search-order. That is, if you give a partial name the
first command that matches that name in this list is the one
executed. Generally, you should specify enough of a command so
that it is completely unique.
HISTORY
Usage : history [-nr] [partial_string]
Example : history
Options :
-n omits line numbering
-r reads history from stdin
Displays the enumerated history list. The size of the list is
controlled by the _history variable. If you specify a partial
string, only those entries matching that string are displayed.
HOWMANY
Usage : howmany
This command tells you how many instances of Shell are running in
your system.
HTYPE
Usage : htype [-r] file1 .. filen
Displays the specified files in hex and ASCII, just like the system
command 'Type file opt h'. Especially suitable for binary files.
If -r is specified, htype displays all files in a directories.
IF
Usage : if [-n] argument conditional argument [then]
or : if [-n] argument
or : if [-n] -f file or -e file
or : if [-n] -d file/dir
or : if [-n] -m
or : if [-n] -t file file1 .. fileN
or : if [-n] -r rpnexpression
or : if [-n] -v varname
or : if [-n] -o char arg ... arg
Makes the following instructions up to the next endif conditinal.
The 'then' is optional. The if clause must be followed by a semi-
colon if instructions follow on the same line.
If a single argument is something to another argument. Conditional
clauses allowed:
<, >, =, ! and combinations. Thus != is not-equal, >= larger or
equal, etc...
If arguments are not numeric, they are compared as strings.
Usually the argument is either a constant or a variable ($varname).
The second form if IF is conditional on the existence of the argument.
If the argument is a "" string, then FALSE, else TRUE.
The third form of IF used by -f switch checks for existance of
the specified file. -e is the same as -f
Switch -d tests the type of the object specified: if it is a
directory, then TRUE; if it is a file (or it doesn't exist)
then FALSE.
Switch -m is used to test if FAST memory is present.
Example (to be included in a login.sh file):
if -m; resident -d lc1 lc2 blink; endif
Using -t form compares the date and time of the first file with
all the others; if the first is younger than ALL the others, then
FALSE, else TRUE. If a file doesn't exists, it is considered as
being older.
This feature is especially useful for building makefiles without
using any MAKE utility.
Example:
if -t test.o test.asm test.i ; asm -o test.o test.asm ; endif
Option -r evaluates a given RPN expression (see under RPN for more
info): if value on top of stack is 0, then FALSE, else TRUE.
Option -o tests for option 'char' in the rest of the arguments.
Example: if -o r -rp ram:comm1.c will yield TRUE.
Switch -n (NOT) reverses the result.
To test if a given variable is defined, use if -v varname.
When using 'IF' command interactively if you are entering commands
following an 'IF' that was false, the prompt will be set to a
underscore '_ ' to indicate all commands will be ignored until
an 'ELSE' or 'ENDIF' command is seen.
INC
Usage : inc varname [value]
Example : inc abc 5
Increment the numerical equivalent of the variable with specified
value (default: 1) and place the ASCII-string result back into
that variable.
INFO
Usage : info [path1 path2 ... pathN]
If called without arguments, info gives you the drive information
on all devices. If one or more paths are specified, only infor-
mation on those drives will be displayed.
INPUT
Usage : input [-s] var var ... var
Example : input abc
Input from STDIN (or a redirection, or a pipe) to a variable. The
next input line is broken up in words (unless quoted) and placed in
the variable. If -s is turned on, the whole line is read in as one
word, including spaces. -r puts the console to single character mode
before reading (ie. does not wait for RETURN to be pressed). Use
this with care.
JOIN
Usage : join [-r] file1..fileN destfile
Example : join part1 part2 part3 total
Joins the specified files to get destfile. If destfile already
exists, an error message is generated and operation is aborted,
unless you specify -r (replace) option.
KEYMAP
Usage : keymap [number {key=function}]
Example : keymap 0 1030=4 1032=12
Defines one keymap for the csh command line editing. See chapter XV.
LABEL
Usage : label name
Create a program label right here. Used in source files, you can
then GOTO a label.
LINECNT
Another filter. Counts the number of lines of its stdin and writes
it to stdout.
LOCAL
Usage: local [var...var]
Creates one or more local variables. Those variables disappear
at the end of their alias or source file, and cannot be accessed
from inside other aliases or source files.
With no arguments, shows all top level variables and their values.
LS
Equivalent to dir.
MD
Equivalent to mkdir.
MAN
Usage : man command(s)
Example : man mkdir
Get info about a Shell command, or others keywords. These include
all special _variables, plus various keywords: WILDCARDS, PIPES,
EDITING, STARTUP and more.
See special alias manlist to get a list of ALL keywords supported
by man.
You must set _man to the paths of your .doc files:
set _man dh1:docs/aliases.doc dh1:docs/csh.doc
To create your own .doc files, precede all your keywords by four
blanks. 'man' will then display lines until the first character
of a line is alphanumeric or has four leading blanks.
MEM
Usage : mem [-cfqu]
Options:
-c shows the free chip mem only
-f shows the free fast mem only
-q outputs just a number without titles
-s stores current free memory
-r shows memory used relative to last stored
-l flushes all unneeded memory
MENU
Usage : menu [-n] [ title item...item ]
Example : menu Shell JrComm,,j Rename,"rename ",r quit
Appends one pull down in the current console window. Up to six
menus with 16 items every can be installed.
If the item is just a string, that string will be in the menu item.
When you select it, it will be put into the prompt and executed.
If there is a comma and after that comma a second string, this
will be the command will be inserted at the prompt. This time you
have to add the ^M yourself if you want the command to be executed.
If there is a second comma, the letter after that comma will be
the keyboard shortcut for that menu item. (This will be case
sensitive some day, use lowercase).
If for any reason your current menu is corrupt, just enter an
empty 'menu' command.
To clear all existing menus use option -n.
MKDIR
Usage : mkdir name name name...
Example : mkdir df0:stuff
Create the specified directories.
MV
Equivalent to rename.
OPEN
Usage : open filename filemode filenumber
Example : open RAM:data w 1
This allows you to open a file, redirect to it as many commands as
you like, then close it.
Filename is any valid AmigaDOS filename, filemode is either "r" for
read or "w" for write, filenumber is a number between 1 and 10.
To redirect a program to or from an open file, use as your redir
filename a dot followed by the filenumber.
Here is a complete example:
open RAM:data w 1
echo -n 2+2= >.1
rpn 2 2 + . CR >.1
close 1
type RAM:data # will display 2+2=4
See also close, flist.
PATH
Usage : path [-r] [dir...dir]
Without arguments, lists AmigaDOS path. Otherwise adds given directories
to the path, preventing duplicate entries.
Options:
-r Resets the path
PRI
Usage : pri clinumber pri
Example : pri 3 5 # set priority of cli #3 to 5
Change the priority of the specified task (use PS command to
determine clinumber). If you specify 0 as clinumber you can
change priority of "this" task (the one executing shell).
PROTECT
Usage : protect file1 ... filen [+|-|=][flags]
Example : protect myfile +rwe
Set AMIGADOS file protection flags for the file specified. Valid
flags are h, s, p, a, r, w, e, d. x ist the same as e. Modes:
+ Set specified bits, leave all others
- Clear specified bits, leave all others
= Set specified bits, clear all others
Specifying no mode is equal to '='. Archive bit cleared by default.
PS
Usage : ps [commandname...commandname]
Gives status of CLI processes. eg:
Proc Command Name CLI Type Pri. Address Directory
* 1 csh Initial CLI 0 97b0 Stuff:shell
2 clock Background -10 2101a8 Workdisk:
3 emacs Background 0 212f58 Stuff:shell
4 VT100 Background 0 227328 Workdisk:
Address is the address of the task, directory is the process
currently CD'd directory. My default, only the BaseNames of
the commands are shown. Your own CLI will be marked by an
asterisk in the first column.
Options:
-l shows full pathnames of commands
-e excludes the given command names from the list
PWD
Usage : pwd
Rebuild _cwd by backtracing from your current directory.
QSORT
Usage : qsort [-r] <in >out
Quick sorts from stdin to stdout. -r causes reverse sorting.
QUIT
Usage : quit
Quit out of Shell back to CLI.
RBACK
Usage : rback command
Start a new process executing the specified command, but can't do
input/output. Equivalent to 'run command >NIL: <NIL:'. Instead of
using rback, you can add a '&' at the end of the command line. The
variable Under 1.3, $_newproc will hold the cli number of the newly
created process.
Note: rback cannot start builtin commands. You have to start a
subshell: rback csh -c "copy ram:temp prt:;rm ram:temp
READFILE
Usage : readfile varname [filename]
Completely reads an ASCII file and assigns it to a variable. Each
line becomes one word in the resulting string. Embedded blanks
are no problem. If file name is omitted, stdin is used. See also
'writefile', @subfile and @flines
RENAME
Usage : rename from to
or : rename from from from ... from todir
Allows you to rename a file or move it around within a disk.
Allows you to move 1 or more files into a single directory.
The archive bit of the file(s) will be cleared.
RESIDENT
Usage : resident [-r][-d] [files]
Example : resident lc1 lc2 blink # load these as resident
resident -d lc1 lc2 blink # defer load when needed
resident -r lc1 lc2 blink # remove these
resident # list resident programs
This is ARP resident. Commands are searched by Shell in resident
list BEFORE of searching on any external device.
Only PURE programs can run as resident, see ARP docs for more info.
Option -d is very useful: you can say, in your startup file,
resident -d file...file; programs will not be loaded immediately,
but only when you will try to load them. This way, you will not
waste memory and startup time if you don't use the programs.
Old option -a has no more effect.
RETURN
Usage : return [n]
Example : return 10
Exit from a script file, or quit from shell with optional
exit code.
RM
Equivalent to delete.
RPN
Usage : rpn expression
Example : rpn 3 7 * # Prints the value 21
Evaluate an RPN expression, using 32-bit values. In older versions
of Shell RPN contained string functions too, but now that strings
are handled by specifical commands, these are no more needed.
At end of evaluation, RPN prints values on stack, so you can
say for instance "rpn $x 2 * | input x" to double the value of
variable x.
Functions implemented are:
+ - * / Obvious meaning; / means integer division, of course
% Module operator e.g. "rpn 7 3 %" answers 1
& | ~ Bitwise and, or, not operators
> < == Tests for greater-than, lower-than, equal. To get
a test for >= (or <=), you can use < ! (or > !)
! Logical not operator
DUP Duplicate value on top of stack
DROP Drop value on top of stack
SWAP Swap two values on top of stack
To avoid confusion with redirections, > and < operators must be
enclosed in quotes e.g.
3 2 ">" # Prints 1
RUN
Usage : run prgm args
Example : run emacs test.c
Start a new process executing the specified command. This command is not
fully reliable: use at your own risk. Under 1.3, $_newproc will hold the
cli number of the new process. See also rback.
RXREC
Usage : rxrec [portname]
Create an AREXX-compatible port of the specified name (defaults to
"rexx_csh"), then puts Shell to sleep waiting for messages on it.
CAUTION: the only way to exit from this status is to send to the port
the message "bye".
Example:
Open two Shell's in two separate CLI's. From the first, type:
rxrec
Now first Shell doesn't respond to keyboard input; instead, it waits
for messages on a port called "rexx_csh". Now, from the other, type:
rxsend rexx_csh "dir df0:"
You will see the listing of df0: in the first Shell. Experiment as you
like, then:
rxsend rexx_csh bye
And all will return to normal.
RXSEND
Usage : rxsend [-lr] portname command...command
Send commands to any program with an AREXX-compatible port. Be aware
that every word is sent as a single command!
You don't have to load anything to use these command (or rxrec):
all you need is a program with the right port.
An example is CygnusEdProfessional: here is, for instance, a command
to wake it up, load the file test.c and jump to line 20:
rxsend rexx_ced cedtofront "open test.c" "jmp to line 20"
# rexx_ced is the name of AREXX port for CygnusEd
The option -r sets the variable _result to the result string
of the AREXX command.
The option -l send the whole line as *one* command.
Refer to your application manual for details and for the names
of the commands and the port.
SEARCH
Usage : search [-abcefnqrvw] file...file string
Search specified files for a string. Only lines containing the
specified strings are displayed.
If the filename is STDIN (in uppercase), the standard input is
used, so you can use search as the destination for a pipe.
Example:
strings myprog * | search STDIN .library
Lists all libraries used in "myprog".
Search is very fast if none of the options -w, -e and STDIN was
specified and the file fits into memory.
Options:
-a (abort) stops search as soon as the pattern was found once
-b (binary) shows only byte offsets instead of lines. If combined
with -n, shows naked numbers.
-c (case) turns ON case sensitivity
-e (exclude) lists lines NOT containing the pattern
-f (files) causes only the names of the files in which the pat-
tern was found to be displayed.
-l (left) pattern must be at beginning of line (this is faster
than using a wild card)
-n (number) turns off line numbering
-o (only) finds only whole words
-q (quiet) suppresses printing of file names.
-r (recurse) if you specify any directory, all files in that di-
rectory are recursively searched.
-v (verbose) shows each file name on a single line. this is auto-
matically turned on if search is redirected
-w (wild) wild card matching. see notes below
Notes to wild card matching;
- Uses Shell standard matching.
- All standard ARP wildcards are allowed * ? [] () | ~ ' #
- The WHOLE line must match the string, not only a substring.
- String MUST be enclosed in quotes to avoid wildcard expansion
Examples:
search -cr df0:include ACCESS
Find all occurrences of ACCESS (in uppercase) in all files
contained in include directory.
search -w shell.h "'#define*"
Lists only lines of file beginning with (not simply containing)
#define. Note the use of ' to escape the special symbol #.
SET
Usage : set [name] [=] [string]
Example : set abc hello
Set with no args lists all current variable settings.
Set with one arg lists the setting for that particular variable.
Specifying name and string, stores the string into variable name.
Also see the section on special _variables.
SETENV
Usage : setenv envvar value
Sets an ENV: variable to the given value. The value must be
enclosed in quotes if it contains spaces. To retrieve an ENV:
variable, just use $envvar anywhere on a command line.
SLEEP
Usage : sleep timeout
Example : sleep 10
Sleep for 'timeout' seconds, or until ^C typed.
SPLIT
Usage : split srcvar dstvar...dstvar
Assigns one word of srcvar to every dstvar, the rest of srcvar to
the last dstvar.
Note: You enter variable NAMES, not variables.
STACK
Usage : stack [number]
Example : stack 8000
Changes the default stack for this CLI. Without arguments, prints
it.
STRHEAD
Usage : strhead varname breakchar string
Example : strhead x . foobar.bas # Will set x to "foobar"
Remove everything after and including the breakchar in 'string' and
place in variable 'varname'.
STRINGS
Usage : strings file1..fileN minlength
Example : strings c:dir c:list shell 7
Prints strings contained in specified files (usually binary)
with length >= minlength.
STRLEFT
Usage : strleft varname string n
Example : strleft x LongString 5 # Will set x to "LongS"
Place leftmost n chars of string in variable varname.
STRLEN
Usage : strlen varname string
Example : strlen x Hello # Will set x to "5"
Puts len of string in variable varname.
STRMID
Usage : strmid varname string n1 [n2]
Example : strmid x LongString 5 3 # Will set x to "Str"
Places n2 chars from string, starting at n1, in variable varname.
By omitting n2, you get all chars from n1 to end of string.
STRRIGHT
Usage : strright varname string n
Example : strright x LongString 5 # Will set x to "tring"
Place rightmost n chars of string in variable varname.
STRTAIL
Usage : strtail varname breakchar string
Example : strtail x . foobar.bas # Will set x to "bas"
Remove everything before and including the breakchar in 'string' and
place in variable 'varname'.
SOURCE
Usage : source file [arguments]
Example : source mymake.sh all
Result : batch file 'mymake.sh' called with var _passed = 'all'
Execute commands from a file. You can create SHELL programs in
a file and then execute them with this command. Source'd files
have the added advantage that you can have loops in your command
files (see GOTO and LABEL). You can pass SOURCE files arguments
by specifying arguments after the file name. Arguments are passed
via the _passed variable (as a single string, a set of words).
See _failat variable for script aborting.
Long lines may be split by appending a backslash (\) at end of
first part. One single line must be shorter than 512 bytes, but
the concatenated line can be as long as you want. There is no
limit on the length of the concatenated line.
Automatic 'sourcing' is accomplished by appending a .sh suffix to
the file (no need to set the s-bit) and executing it as you would
a C program:
--------- file hello.sh ---------
foreach i ( $_passed ) "echo yo $i"
---------------------------------
$ hello a b c
yo a
yo b
yo c
If the last character of a line in a source file is '{', all
following lines will appended to the current one and separated
by semicolons until the last character of a line is '}'. Those
blocks may be nested. You may use comments and unterminated
strings within.
--------- file login.sh ---------
alias complex {
echo -n "this alias
echo " works!"
}
---------------------------------
$ login
$ complex
this alias works!
TACKON
Usage : tackon var pathname filename
Example : tackon x df0:c Dir # sets x to "df0:c/Dir"
or : tackon x df0: Preferences #sets x to "df0:Preferences"
Correctly adds a filename to a pathname, and puts the result in
variable specified.
TAIL
Usage : tail filename [num]
Example : tail readme 20
Display last "num" lines of "filename". If num is not specified,
10 is assumed.
TEE
Usage : tee [file]
Example : cc test.c | tee >error.list
Copies stdin to stdout and the given file. If file is omitted, stderr
is used.
TOUCH
Usage : touch file1 .. fileN
Sets DateStamp of the specified files to the current date & resets
archive bit.
TRUNCATE
Usage : truncate [n]
Example : alias | qsort | truncate
A filter that truncates the width of stdin to the specified number,
trying to account for tab's and escape sequences. If the number is
omitted, the current window width is used.
TYPE
Equivalent to CAT.
UNALIAS
Usage : unalias name .. name
Example : unalias vt
Delete aliases..
UNIQ
Usage : uniq
This is a filter that removes consecutive, duplicated lines in a
file. It is most useful on a sorted file.
UNSET
Usage : unset name .. name
Example : unset abc
Unset one or more variables. Deletes them entirely.
USAGE
Usage : usage [command...command]
If called without arguments, usage gives you a short information
on the special characters used. Otherwise, usage shows you the
usage of the given commands. Calling a command with a '?' as
the only argument will show its usage, too.
VERSION
Usage : version
Show current version name, & authors.
WAITFORPORT
Usage : waitforport portname [seconds]
Example : waitforport rexx_ced 5
Waits for a port to come up. Default time is 10 seconds.
WHEREIS
Usage : whereis [-r] filename [ device1...deviceN ]
If just a file name is given, whereis searches all subdirectories of
the current directory for that file. An asterisk '*' is appended to
the file. Wild cards are allowed for the file (no asterisk will be
appended then), but no path names. If additional arguments are
given, whereis searches only these paths, not the current directory.
whereis -r looks on all drives.
WINDOW
Usage : window [-q][-f][-b][-l][-s] [dimensions]
Options :
-f (front) Window to front
-b (back) Window to back
-l (large) Window to maximum size
-s (small) Window to minimum size
-a (activate)
-q (query) Lists screens and windows open
Various operations on CLI window. If dimensions are specified,
they must be in the form x y width height, with values separated by
spaces.
The command "window -l" may be very useful on PAL machines to
get a full PAL window from your login sequence, or if you use
overscan WorkBench.
Option -q gives, for each Screen and Window currently open,
title, left edge, top edge, width, height, (depth).
WRITEFILE
Usage: writefile varname
Writes a set of words to stdout, one word per line. Note that the
name of the variable (var) must be supplied, not the value ($var).
IX. SPECIAL VARIABLES
---------------------
There are a number variables, the write variable, that have a side effect on
your system (e.g. changing the title bar), and some others, the read
variables, that tell you something about your environment (e.g. the current
shell version). You can also overlay the write variables with a local
variable, so any change only takes place while the current context is
valid.
_abbrev
If set to 'n', internal commands can no longer be abbreviated.
_bground
True if the shell was started with a non-interactive input.
_clinumber
Contains the number (1-20) of current CLI.
_cwd
Holds a string representing the current directory we are in from
root. The SHELL can get confused as to its current directory if
some external program changes the directory. Use PWD to rebuild
the _cwd variable in these cases.
_debug
Debug mode... use it if you dare. must be set to some value
_every
Contains the name of a command that is to be executed every time
just before the prompt is printed. Do not use this to echo the prompt.
_except
See EXCEPTION
_failat
If a command returns with an error code higher than this, the
batch file aborts. The default is 20.
_hilite
Holds the font attributes used for highlighting. One letter for one
attribute:
b for bold
i for italic
u for underlined
r for reverse
c3 for foreground color 3
c3,2 for foreground color 3 and background color 2
Any combinations are allowed. _hilite defaults to "c7", in terminal
mode to "r".
_history
This variable is set to a numerical value, and specifies how far
back your history should extend. Set it to 0 to disable history,
for example if you test your programs for memory leaks. Defaults
to 50.
_insert
Sets the default for insert/overtype mode for command line editing.
ESC-i toggles between, but after <RET> the default is set back as
indicated by this variable. By default _insert is 1, unsetting
_insert will make overtype the default.
_ioerr
Contains the secondary error code for the last command. Will be
changed after every external command and after a failed internal
command. See @ioerr( )
_kick2x
True if dos.library V36 could be opened (which means that kickstart
2.0 is around)
_lasterr
Return code of last command executed. This includes internal
commands as well as external comands, so to use this variables
you must check it IMMEDIATELY after the command in question.
_lcd
Holds the name of the last directory. The builtin alias 'dswap'
cd's to that directory. If called again, you're back where you
were.
_man
The path and name of your .doc files. Defaults to 'csh:csh.doc'
_maxerr
The worst (highest) return value to date. To use this, you usually
set it to '0', then do some set of commands, then check it.
_minrows
Gives the minimum number of rows a window must have to turn on quick
scrolling. Defaults to 34.
_nobreak
If set to some value, disables CTRL-C.
_noreq
If set to some value , disables system requesters ("Please insert
volume ...."). Turned on in vt200 mode.
_passed
This variable contains the passed arguments when you SOURCE a file
or execute a .sh file. For instance:
test a b c d
-------- file test.sh ----------
echo $_passed
foreach i ( $_passed ) "echo YO $i"
--------------------------------
_path
Tells CShell where to look for executable files. The current direc-
tory and the AmigaDOS path will be searched first. The trailing
slash for directories is not necessary anymore. The entire path
will be searched first for the <command>, then for <command>.sh
(automatic shell script sourcing). Example:
set _path ram:c,ram:,sys:system,dh1:tools,df0:c
(This path has the advantage that these directories need not even
exist, that you can access devices (AmigaDOS path only knows
volumes under Kick 1.3) and that no disk seeks happen at startup)
_prompt
This variable now can contain the following control characters:
%c for color change. This highlights your prompt. See _hilite
%e for elapsed time. The time the last command took to execute.
%m for memory. This shows your current memory in K
%t for time. This shows your current time in the format HH:MM:SS
%d for date. This shows the current date in the format DD-MMM-YY
%p for path. This inserts the current path
%n for number. This inserts the current process number
%v for version. This shows the version number of CShell
%h for history. This displays the current history number
%f for free store. This shows the free store on the current drive
%r for pRiority. Inserts the task priority of the current
%s for shells open. Inserts the result of 'howmany'
%x for external cmd return code. Yields the last error code
The default for prompt is now "%c%p> "
The if command will set the prompt to a '_ ' if commands are
disabled while waiting for a 'endif' or 'else' command (interactive
mode only).
_pipe
The directory where temporaries are stored. Default: 'T:'
_qcd
Holds the name of the file where the all directories on your hard
disk are stored. If not set, disables quick cd-ing.
_rback
Is the name of the command to be the prepended to the command line
when '&' was added to it. Defaults to 'rback', can't be a multi
word command yet.
_rxpath
The same as with _path, but this is where CShell looks for .rexx
files. Defaults to REXX:
_scroll
Holds the number of lines to be scrolled at once when quick scrolling
is used. If unset or <=1, quick scrolling is off. Defaults to 3.
_terminal
Indicates whether or not shell was started in terminal mode.
_titlebar
The same control characters as for the _prompt can be used for
_titlebar, too. The only difference is that %c is ignored. The
titlebar is updated every time before the prompt appears.
_verbose
If set to 's', turns on verbose mode for source files (every command
will be displayed before being executed). If set to 'a', displays
all substeps while alias substitution. 'h' will hilight the debug
output. Any combination allowed: set _verbose sah
_version
Contains the version number of the shell, e.g. 510.
X. FUNCTIONS
--------------
FUNCTIONS
Functions are preceded by an @-sign and may not be abbreviated
They must be preceded by a blank and a blank must follow the opening
and precede the closing parenthesis. There must be no blank between
the function name an the opening parenthesis. Example:
echo @info( df0: )
(NOTE: Later versions of Shell might allow that functions need not
be at the beginning of an argument, so quote any @-signs not
used for functions)
Functions may be nested. The function names themselves are case
sensitive, but the operations (like strcmp) aren't.
Functions can be used as commands. They will echo their return value
to stdout. Note that they can't be abbreviated and that the function
list is searched after the command list. Example:
drives ---> DF0: DH1: DH2: RAM: WB_2.x:
Therefore, functions can also be used like this:
echo $(drives)
So far, functions are not user definable.
Note the difference between sets of words and strings. After
set var hello world
$var is a wordset, but after
set var "hello world"
var is one string. Although they look the same if echoed, they
behave different, for example in 'foreach i ( var ) "echo hi'. The
functions @split and @concat convert the two forms.
@abbrev( str1 str2 [len] )
true if the first <len> chars of str1 are an abbreviation of str2
@abs( num )
returns absolute value of <num>
@age( file )
the age of that file in days, 99999 if file not found
@appsuff( name suffix )
appends an suffix ( .ZOO ) to a string if it's not already there
@arg( arg ... arg )
see @pickargs( )
@availmem( [type] )
returns free 'chip', 'fast' or otherwise total memory
@basename( path ... path )
returns the file name parts of the paths
@center( word len )
returns a string of length <len> with <word> centered in it
@checkport( portname )
indicates if given port exists
@clinum( procname )
returns the number of the cli identified by a name or a number
@complete( abbrev word ... word )
returns the first word <abbrev> is an abbreviation of
@concat( word word ... word )
concats all words in one blank separated string, see @split
@confirm( title item ... item )
asks for confirmation of every item and returns the confirmed ones
@console( STDIN|STDOUT )
tells whether stdin or stdout are interactive (not redirected)
@dectohex( number )
returns a string representing <number> in hex
@delword( word word ... word n )
returns a string with the n-th word deleted.
@delwords( word word ... word n m )
deletes the next m words from the n-th.
@dirname( path )
strips the base name from a path, just returns the directory
@dirs( name name name name )
returns the directories among the given file names, see @files
@dirstr( lformat file )
returns any info (size, date, file comment) about a file
@drive( path )
outputs the drive ( device ) name associated to <path>
@drives( )
outputs all available drives
@exists( file )
tells whether a file exists or not
@fileblks( file file ... file )
returns the # of blocks needed for the files, incl. dir blocks
@filelen( file file ... file )
count the total number of bytes of the given files
@fileprot( file )
returns a string like ---arwed
@filereq( title path&pattern filename )
brings up the ARP file requester and returns the selected file name
@files( file file ... file )
gives you the files among those names, no directories. see @dirs
@flines( varname )
counts the number of lines in a readfile-file (faster than @words)
@freebytes( path )
the number of free bytes on the given path
@freeblks( path )
the number of free blocks on the given path
@freestore( path )
the amount of free store on that path, given in K, M and G
@getenv( varname )
returns the value of the named env: variable
@getclass( file )
returns the class (type) of the file. See chapter XIV
@howmany( )
indicates the # of shells running
@index( string pattern )
returns the index of pattern in string (starting at 1), 0 if not found
@info( path )
the corresponding line from the 'info' command, each entry a word
@intersect( word1 word2 word3 , word4 word5 word6 )
returns all words which are in both lists. see @union, @member
@ioerr( num )
returns the corresponding error string to num
@lookfor( file paths )
looks for a file in the current directory and the paths. See $_path
@lower
lowercases its arguments. see @upper
@match( word ... word "pattern" )
returns the words in the list that match the ARP-pattern
@max( num num ... num )
computes the maximum of all given numbers
@megs( number )
expresses a number in K, M and G (-bytes), rounded correctly
@member( word1 word word ... word )
tells you if word1 is among the remaining words
@min( num num ... num )
computes the minimum of all given numbers
@mix( arg1 ... argn )
randomly mixes its arguments
@mounted( device )
returns a boolean indicating whether the specified device is mounted
@nameext( filename )
returns all after the last dot of <filename>.
@nameroot( filename )
returns all before the LAST dot of <filename>.
@opt( arg ... arg )
see @pickopts( )
@pathname( path )
obsolete. use @dirname
@pickargs( arg ... arg )
picks of its arguments those which don't start with a '-'
@pickopts( arg ... arg )
picks of its arguments those which start which a '-'
@rnd( )
returns a 32 bit random number
@rpn( expression )
computes the rpn expression. See rpn command
@scrheight( )
outputs the current height of the screen the shell is running in
@scrwidth( )
outputs the current width of the screen the shell is running in
@sortargs( name ... name )
sorts its arguments alphabetically
@sortnum( number ... number )
sorts its arguments numerically
@split( string )
makes each blank separated part of @string a word, see @concat
@strcmp( name name )
returns -1, 0 or 1 depending of alphabetical comparison
@strhead( breakchar string )
see strhead command
@strleft( string number )
see strleft command
@strmid( string n1 n2 )
see strmid command
@strright( string n )
see strright command
@strtail( breakchar string )
see strtail command
@subfile( varname n m )
like @subwords, but acts on a readfile-file and is faster
@subwords( word ... word n m )
returns the next m words word of the given list starting from n
@tackon( path file )
see tackon command
@trim( word word word )
removes all leading and trailing blanks from the words
@unique( word ... word )
sorts the arguments and makes each of them unique
@union( name ... name , name ... name )
returns all names that are in either list. See @intersect, @member
@upper( word ... word )
upper cases the given words. see @lower
@volume( path )
returns the volume name in that path or ""
@wincols( )
returns the number of columns in the current shell window
@winheight( )
outputs the height of your window in pixels
@winleft( )
returns the left edge of your window
@winrows( )
returns the number of lines in the current shell window
@wintop( )
returns the top edge of your window
@winwidth( )
outputs the width of your window in pixels
@without( name ... name , name ... name )
returns all names of list 1 that are not in list 2
@word( name ... name n )
picks the n-th word from the list.
@words( name ... name )
returns the number of words in the list.
XI. MISCELLANEOUS
-----------------
CShell now allows to do quick scrolling in large windows. Quick
scrolling means that whenever the cursor reaches the bottom of
the window, the text jumps up 3 or more lines at once. However,
only the following commands support this:
dir, cat, htype, strings, search, truncate, tee
You can choose the number of lines to scroll at once by setting
the variable _scroll. Unsetting it or setting it to a value <=1
completely disables quick scrolling.
You can also choose the number lines a window must at least have
to turn on the quick scrolling by setting the _minrows variable.
(Defaults to 34). Quick scrolling is automatically disabled when
the command is redirected. By piping any command to cat, you can
force it to quick scroll. Example: List | cat
CShell now can be terminated using the closing gadget in the
AmigaDOS 2.0 shell window. Don't execute c:ENDCLI while using
the shell. This can cause problems with external commands. The
closing button provides a 'quit' command. You can define
alias quit "Endcli;\\quit
to assert that the CLI window closes when you click the button.
EXCEPTIONS
If no _except variable exists, any command which fails causes the
rest of the line to abort as if an ABORTLINE had been executed. If
the _except variable exists, it is of the form:
"nnn;commands..."
where nnn is some value representing the minimum return code
required to cause an error. Whenever a command returns a code
which is larger or equal to nnn, the commands in _except are
executed before anything. WHEN _except EXISTS, THE COMMAND LINE
DOES NOT ABORT AUTOMATICALLY. Thus, if you want the current line
being executed to be aborted, the last command in _except should be
an "abortline".
Exception handling is disabled while in the exception handling
routine (thus you can't get into any infinite loops this way).
Thus if _except = ";", return codes are completely ignored.
Example:
set _except "20;abortline"
XII. EXAMPLE SOURCE FILES
-------------------------
If from a CLI or the startup-script you say 'SHELL filename', that file is
sourced first.
### compat.sh ###
# this makes sure that your old abbreviations don't call new commands
alias as aset
alias cl close
alias g goto
alias h help
alias he help
alias m md
alias q quit
alias re rename
alias w window
alias kr "rm -r ram:* >NIL:
### End of compat.sh ###
Moreover, if you have a file called S:.login, it will be sourced for every
Shell you run. This is useful for aliases and setting that you want in ALL
Shells.
### Example S:.login ###
Here is an example .login file:
set F5 "cdir WORK:"^M
set f9 "ed s:login.sh"^M
set F9 "ed df0:s/startup-sequence"^M
alias toram "%q foreach i ( $q ) \"cp -r $i: ram:$i >NIL:;assign $i: ram:$i
alias ramop "md RAM:op; assign OP: ram:op
alias noop "assign OP: ; rm -r ram:op
alias newop "rm -r OP:*
alias dc "dfc df0: to df1:
alias go "%q assign WORK: Boot:$q; cd WORK:; source startme.sh
alias get "%q cp $q RAM: >NIL:
alias filter "%a%b%c exec $b \\<$a \\>$c
# reads $a, filters it with $b and writes result to $c
alias rm "%q \\rm @confirm( Remove $q )
#alias rm "%a set f @pickargs( $a );set opts @pickargs( $a );\
# e -n OK to delete @words( @files( $f ) ) file(s) and @words( @dirs( $f ) )\
# directories\"? \";input b;if $b = y;\\rm $opts $f;endif
# # for the anxious among us: confirmed rm
set _prompt "%c%p> "
# this puts the path highlighted in the prompt
# this one puts cli number, free mem, date and time in title bar
set _titlebar "Shell %n Mem %m Date %d Time %t
# This file will be sourced for every Shell you start
### End of example .login ###
****************************************************************************
If you are a CLI user, your startup-sequence may be as simple as:
C:csh S:startup.sh
Here's a startup code:
### Example S:startup.sh ###
wind -l # if you are on a PAL machine, or use overscan
# note that commands may be abbreviated (wind=window)
assign LC: Stuff:c INCLUDE: Stuff:include LIB: Boot:lib QUAD: RAM:
rback C:FaccII; sleep 1
# after spawning a process, it is always better to allow it
# to load the command, to avoid excessive drive head movement
resident -d blink lc1 lc2 >NIL: #defer loading
C:PopCli 300 C:Newcli #using full pathname loads faster
C:FF -1 Siesta.font >NIL:
C:Patch_1 >NIL:
stack 8000 # lc1 and lc2 need this
source S:setdate.sh # this is listed next
### End of example startup.sh ###
****************************************************************************
The following is an example source file to set date and time; it may be
used at startup if you don't have an internal clock.
### setdate.sh ###
open CON:200/100/440/80/SetDate write 1
echo >.1 -n "Current date is "
date >.1
echo >.1 -n "Please enter date: "
input <.1 d
close 1
strlen len $d
if $len > 1 ; date $d ; endif
echo -n "New date: " ; date
### End of setdate.sh ###
***************************************************************************
Next comes a makefile that needs no Make program: may be executed from
Shell directly!!!
### make.sh ###
if -t Shell.syms Shell.h; cc +HShell.syms Shell.h; rm shell.o; endif
if -t RAM:Shell.syms Shell.syms; cp -d Shell.syms RAM:; endif
foreach i ( main comm1 comm2 comm3 execom globals rawconsole run set \
sub ) "if -t $i.o $i.c; echo Compile $i...;cc +IRAM:shell.syms $i.c; endif"
# we used line continuation for better visibility. this is not necessary,
# you can type it all in one line. no more limit of 256 bytes per line
if -t Shell run.o main.o comm1.o comm2.o comm3.o execom.o \
set.o sub.o globals.o rawconsole.o
ln +q -m -o Shell run.o main.o comm1.o comm2.o comm3.o\
execom.o set.o sub.o globals.o rawconsole.o -la -lc
endif
### End of make.sh ###
XIII. Default Values
--------------------
Some aliases are predefined whenever you start a new Shell. These are:
CDIR
Use "cdir directory" to clear the screen, set CD to directory,
and list it.
CLS
Simply clear the screen.
DSWAP
Exchanges current and the previous current directory. For use in
scripts as the symbol for last current directory may change.
EXIT
Leave Shell and exit CLI.
MANLIST
Display a list of possible arguments to man.
RX
Executes a REXX script. Prevents unwanted starting of 'rxrec'.
Moreover, many variables have default values, and many function keys are
predefined. You can use set command to determine all of these.
XIV. Object oriented features
------------------------------
File classes are good for two things: Identifying files and command over-
loading. The latter means that the same command with files of different
type performs completely different actions.
CLASSES OF FILES
You can define a class of files using several 'class' commands.
Here a simple example:
class picture suff=.pic suff=.iff suff=.ilbm
class anim suff=.anim
From now on, everything with the suffix .pic, .iff or .ilbm will
be identified as a picture. Please note that there may be no blanks
between the names and the '=', and that blanks inside the names
must be put in quotes. So these are the ways to identify a file:
suff=.doc True if the suffix of the file is .doc
name=readme True if the file is "readme"
name="mod.*" True if the name starts with 'mod.'
offs=14,DC..C4FD True if the bytes starting at $14 are $DC,
anything, $C4, $FD (all numbers hexadecimal!).
Each pair of dots means one byte ignored.
chars True if 90% of the bytes in the file are 32..127
or 9..13
default Always true, used to define the default type
Note that only the first character is examined, so 's' = 'suff'.
One class can be identified by more than one 'class' statement.
They are looked at in the same sequence they were entered. So to
make sure that an zoo archive misnamed as .lzh is identified
correctly, use the following 'class' statements:
class zoo offs=14,DCA7C4FD
class lzh offs=2,2D6C68..2D
class zoo suff=.zoo
class lzh suff=.lzh
Moreover, there is a builtin class 'dir', which means directory.
Now we know many file types. But what to do with them? This is
where we define 'actions'.
ACTIONS ON CLASSES
There may be one or more 'class' commands that define what actions
need to be taken in various cases for that specific class:
class zoo actions view="zoo -list" extr="zoo -extract"
class lzh actions view="lz l" extr="lz e"
Whenever somebody tries to 'view' a test.zoo, the command
'zoo -list test.zoo' will be issued, but if he tries to
view test.lzh, then 'lz l test.lzh' will be executed. Note
that any command supplied here goes through the normal csh
parser, so AmigaDOS and csh paths will be searched. Aliases
with arguments are allowed here, too, so whatever the user
typed will be stored in the variable after the '%'.
How do I tell a file that I want to 'view' it? There comes the
second command used for object oriented features:
action view test.zoo
will first identify the type of that file and then apply, if
possible, the 'view' action to it. Of course, this works best
inside an alias: alias v "action view" will define a v-command
that views all types of files known to cshell. Similarly, you
can define alias xtr "action extr" and use this command to
extract files from any type of archive.
There is one action that will be sent to every file that you
try to start but is not executable. This action is 'exec'.
Assume you have defined the class 'picture', then after
class picture actions view=Mostra exec=Mostra
you can display a picture using Mostra by just typing its name.
More builtin actions like 'rm' and 'dir' may be implemented,
so don't use command names for action names.
The batch file class.sh defines a few useful classes.
SUPERCLASSES
Assume you have a class for .c files, one for .h files, and
one for .asm files. You might want to make the difference
between them when identifying them, but in the end, they're
all ASCII, aren't they? You can stat this with the command
class c_source suff=.c is=ascii
Now whenever an action on a file of the type c_source fails,
the file is interpreted as of type ascii, and the same
action is attemted again. This goes on until a class has no
more superclass.
XV. Keymaps
---------------
You define a keymap as a collection of key/function pairs. Both
are given as numbers. There can be several keymaps which activate
each other, but at first we only edit keymap 0, which is active
at the beginning. All keys you define will eventually overwrite
the old definitions in an existing keymap. Everything marked with
a (*) is not yet implemented.
KEYCODES
1..255 The corresponding ASCII character
256 Up Arrow
257 Down Arrow
258 Right Arrow
259 Left Arrow
260 Help
261..270 F1..F10 (unshifted)
Modifiers (add them to the key code)
512 SHIFT (only necessary for arrows and fkeys)
1024 ESC (was pressed & released before this key)
EDITFUNCTIONS
- Movement Move cursor...
0 CursLeft 1 left
1 CursRight 1 right
2 WordLeft 1 word left
3 WordRight 1 word right
4 BegOfLine to beginning of line
5 EndOfLine to end of line
- Deleting Delete...
10 Backspace char left from cursor
11 Delete char right from cursor
12 BkspcWord word left from cursor
13 DelWord word right from cursor
14 DeleteToSOL to start of line
15 DeleteToEOL to end of line
16 DeleteLine whole line
- History insert
20 Back Move one line back in history
21 Forward Move one line forward in history
22 Beg Move to first line in history
23 End Move to last line in history
24 Complete History retrieve like '!'
25 Exec Execute history line & bring up next
26 Tail Insert previous line except first word
27 Bottom Go below last history command
28 DupWord Duplicates the last word on this line
- Completion
30 Normal Insert first matching file (or cycle)
31 Partial Insert common substring of all matching files
32 All Insert all matching files
33 Directory Find dir in quick cd list
34 LastCD Insert last current directory
35 Show Shows all matching files
- Special
40 Insert Toggle Insert/Overwrite
41 Quit Silently perform 'quit'
42 Help Silently perform 'help'
43 Refresh Redraw current line
44 Execute Execute current line
45 Leave Edit new line, store this in hist
46 EOF Terminate shell
47 NOP Do nothing
48 Echo^O Echoes a ^O
49 Beep Echoes a ^G
- Other
50 Fkey Execute command associated to last fkey
51 Menu Execute command associated to last menu
52 Undo Undoes last edit
53 Repeat Repeats last function
54 SwapChar Swaps the two chars left of cursor
Command types
0 +x Editing function x, see above descriptions
512 +x Setmap x, x=0..7
1024+x Insert key x, x=1..255
1536+x Macro x x=1..15 (*)
2048+x String x x=1..15 (*)
Examples:
keymap 0 66=49 # the B key will beep
keymap 0 2=16 # ^B key will erase line
keymap 0 1122=35 # ESC-b will show matching files
keymap 0 9=31 521=30 # Swaps TAB and SHIFT-TAB